From: emellor@ewan Date: Sun, 18 Sep 2005 13:42:13 +0000 (+0100) Subject: Add behaviour to the remove methods to remove the transaction's path itself. This... X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~16780^2~47^2~7 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=c353c7fdd0591c8ddc51b95abe3e755878c7c2a1;p=xen.git Add behaviour to the remove methods to remove the transaction's path itself. This allows us to write Remove(path) to remove the specified path rather than having to slice the path ourselves. --- diff --git a/tools/python/xen/xend/xenstore/xstransact.py b/tools/python/xen/xend/xenstore/xstransact.py index d76dd88a90..e15ebdb922 100644 --- a/tools/python/xen/xend/xenstore/xstransact.py +++ b/tools/python/xen/xend/xenstore/xstransact.py @@ -89,10 +89,15 @@ class xstransact: return xshandle().rm(path) def remove(self, *args): + """If no arguments are given, remove this transaction's path. + Otherwise, treat each argument as a subpath to this transaction's + path, and remove each of those instead. + """ if len(args) == 0: - raise TypeError - for key in args: - self._remove(key) + xshandle().rm(self.path) + else: + for key in args: + self._remove(key) def _list(self, key): path = "%s/%s" % (self.path, key) @@ -188,6 +193,10 @@ class xstransact: Write = classmethod(Write) def Remove(cls, path, *args): + """If only one argument is given (path), remove it. Otherwise, treat + each further argument as a subpath to the given path, and remove each + of those instead. This operation is performed inside a transaction. + """ while True: t = cls(path) try: